package com.example.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.entity.Role;
import com.example.demo.entity.UserRole;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface UserRoleMapper extends BaseMapper<Role> {

    @Results({
            @Result(property = "roleId",column = "roleId"),
            @Result(property = "role",column = "roleId",
                    one = @One(select = "com.example.demo.mapper.RoleMapper.selectRoleById"))
    })
    @Select("select * from user_role where userId=#{userId}")
    UserRole selectRoleByUserId(Integer userId);
}
